{include file="public/head"}
<style>
    .x-body {
        min-width: 600px;
    }

    body {
        overflow-x: scroll;
    }
</style>
<body>
<div class="x-body">
    <div class="lotus-nav">
        <button class="layui-btn layui-btn-sm"
                onclick="x_admin_show('添加属性对照','contrastAdd.html?platform_id={$Think.get.platform_id}',500,500)">
            <i class="layui-icon layui-icon-add-circle"></i>添加属性对照
        </button>

        <button class="layui-btn layui-btn-sm layui-btn-danger" onclick="delAll()">
            <i class="layui-icon"></i>批量删除属性对照
        </button>

        <span class="x-right">共有数据:<i class="i_count">{$list->total()}</i>条
        <button onclick="javascript:location.reload()" class="layui-btn-default ">
            <i class="layui-icon layui-icon-refresh"></i>
        </button>
        </span>
    </div>


    <table class="layui-table">
        <thead>
        <tr>
            <th style="width: 75px;text-align: center">
                <div class="header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>产品属性</th>
            <th>关联自定义属性</th>
            <th style="width: 120px;text-align:center">所属平台</th>
            <th style="width: 120px;text-align:center">创建时间</th>
            <th style="width: 85px;text-align:center">操作</th>
        </thead>
        <tbody>

        {volist name="list" id="vo"}
        <tr>
            <td style="text-align:center">
                <div class="layui-form-checkbox" lay-skin="primary" data-id='{$vo.id}'><i
                        class="layui-icon">&#xe605;</i></div>
                {$i}
            </td>
            <td>{$vo.shuxing}</td>
            <td>{$vo.property}</td>
            <td style="text-align:center">{$Think.get.name}</td>
            <td style="text-align:center">{$vo['timestamp']|date="Y-m-d H:i",###}</td>
            <td style="text-align:center">
                <button class="layui-btn layui-btn-xs"
                        onclick="x_admin_show('编辑属性对照信息','contrastEdit.html?id={$vo.id}','500','500')">编辑
                </button>
                <button onclick="del(this,'{$vo.id}')" class="layui-btn layui-btn-xs layui-btn-danger">
                    删除
                </button>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page">
        <div>
            {$list->render()}
        </div>
    </div>
</div>
</body>
{include file="public/foot"}
<script>
    //删除所有
    function delAll() {
        var count = $(".i_count")[0].innerText;
        var data = tableCheck.getData();
        var num = data.length;
        if (num == 0) {
            layer.msg("请选择需要删除的属性对照信息");
            return false;
        }
        layer.confirm('确认要全部删除吗？', function (index) {
            //捉到所有被选中的，发异步进行删除
            $.post("{:url('admin/platform/contrastDel')}", {id: data}, function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        $(".layui-form-checked").not('.header').parents('tr').remove();
                        $(".i_count").html(count - num);
                    });
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                }

            });
        });
    }

    function del(obj, id) {
        var count = $(".i_count")[0].innerText;
        layer.confirm("确认要删除吗？", function (index) {
            //捉到所有被选中的，发异步进行删除
            $.post("{:url('admin/platform/contrastDel')}", {id: id}, function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        $(obj).parents('tr').remove();
                        $(".i_count").html(count - 1);
                    });
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000});
                }

            });
        });
    }
</script>
